﻿@using System.Globalization
@{
    int currentPage = ViewBag.CurrentPage;
    var countRecord = ViewBag.countRecord;
    double pageSize = Convert.ToDouble(ViewBag.PageSize);
    Double floatTotalPage = (countRecord / pageSize);
    int totalPage = (int)floatTotalPage;
    if (totalPage < floatTotalPage)
    {
        totalPage++;
    }    
}
<div class='widget-bottom'>
     <div class='dataTables_paginate paging_full_numbers' id='DataTables_Table_2_paginate'>
               @if (currentPage == 1)
               {
                   <a class='first paginate_button paginate_button_disabled' tabindex='1' id='DataTables_Table_2_first' href="@(1)">First</a> 
                   <a class='previous paginate_button paginate_button_disabled' tabindex='2' id='DataTables_Table_2_previous' href="#">Previous</a>
               }
               else
               { 
                   <a class='first paginate_button ' tabindex='1' id='DataTables_Table_2_first' href="@(1)">First</a>
                   <a class='previous paginate_button ' tabindex='2' id='DataTables_Table_2_previous' href="@((currentPage - 1))">Previous</a> 
                }
                <span>
                   @if ((currentPage - 3 > 0))
                   {
                       <a class='paginate_button' tabindex='3' href="@((currentPage - 3))">"
                           + (currentPage - 3) + "</a>
                   }
                   @if (currentPage - 2 > 0)
                   {
                       <a class='paginate_button' tabindex='4' href="@((currentPage - 2))">
                           @(currentPage - 2)
                       </a>
                   }
                   @if (currentPage - 1 > 0)
                   {
                       <a class='paginate_button' tabindex='5' href="@((currentPage - 1))">@(currentPage - 1)</a>
                   }
                   <a class='paginate_active' tabindex='6' href="@(currentPage)">@currentPage</a>
                   @if ((currentPage + 1 <= totalPage))
                   {
                       <a class='paginate_button' tabindex='7' href="@((currentPage + 1))">@(currentPage + 1)</a>
                   }
                   @if (currentPage + 2 <= totalPage)
                   {
                       <a class='paginate_button' tabindex='8' href="@((currentPage + 2))">@(currentPage + 2)</a>
                   }
                   @if (currentPage + 3 <= totalPage)
                   {
                       <a class='paginate_button' tabindex='9' href="@((currentPage + 3))">@(currentPage + 3)</a>
                   }
                </span> 
                @if (currentPage == totalPage)
               {
                    <a class='next paginate_button paginate_button_disabled' tabindex='10' id='DataTables_Table_2_next' href="#">Next</a> 
                    <a class='last paginate_button paginate_button_disabled' tabindex='11' id='DataTables_Table_2_last' href="#">Last</a>
               }
                else
                { 
                    <a class='next paginate_button' tabindex='10' id='DataTables_Table_2_next' href="@((currentPage + 1))">Next</a> 
                    <a class='last paginate_button' tabindex='11' id='DataTables_Table_2_last' href="@((totalPage))">Last</a>
               }
     </div> 
    <div class='clear'>
         
    </div> 
</div>